import 'package:flutter/material.dart';

main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
        debugShowCheckedModeBanner: false, home: CFDHomePage());
  }
}

class CFDHomePage extends StatelessWidget {
  const CFDHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text("第一个flutter程序"),
          backgroundColor: Colors.yellow,
        ),
        body: const CFDContentBody());
  }
}

class CFDContentBody extends StatefulWidget {
  const CFDContentBody({super.key});

  @override
  State<StatefulWidget> createState() {
    return CFDContentBodyState();
  }
}

class CFDContentBodyState extends State<CFDContentBody> {
  var flag = true;

  @override
  Widget build(BuildContext context) {
    return Center(
        child: Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Checkbox(
            value: flag,
            onChanged: (value) {
              setState(() {
                flag = value!;
              });
            }),
        const Text('同意协议')
      ],
    ));

    //Checkbox(value: flag, onChanged: onChanged)
  }
}

// class CFDContentBody extends StatelessWidget {
//   @override
//   Widget build(BuildContext context) {
//     // TODO: implement build
//     return Center(
//       child: Row(
//         mainAxisAlignment: MainAxisAlignment.center,
//         children: <Widget>[
//           Checkbox(
//             value: true,
//             onChanged: (value) {
//               print(value);
//             },
//           ),
//           Text("你好啊"),
//           Text("Hello")
//         ],
//       ),
//         // child: Text(
//         //   "Hello World",
//         //   textDirection: TextDirection.ltr,
//         //   style: TextStyle(
//         //       color: Colors.blue,
//         //       fontSize: 30
//         //   ),
//         // )
//     );
//   }
//
// }